const BASE_URL = 'http://test.shop.com/api';
function request({ url, data, method }) {
  return new Promise((resolve, reject) => {
		uni.request({
			url:BASE_URL+url,
			data:data,
			header:{
				Accept:'application/json',
				'Content-Type':'application/json',
				'X-Requested-With':'XMLHttpRequest'
			},
			method:method,
			sslVerify:true,
			success:({data,statusCode,header})=>{
				// console.log(data)
				if (data.status == 200) {
				  resolve(data);
				} else {
				  uni.showToast({
				    title: data.msg,
				    icon: 'none',
				    mask: true,
				    duration: 3000
				  });
				  reject(data.msg);
				}
			},
			fail(error) {
				
			}
		});
	});
}

export default request;
